package com.ruoyi.blog.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.blog.mapper.BlogLikeMapper;
import com.ruoyi.blog.domain.BlogLike;
import com.ruoyi.blog.service.IBlogLikeService;

/**
 * 点赞Service业务层处理
 * 
 * @author tina
 * @date 2021-06-27
 */
@Service
public class BlogLikeServiceImpl implements IBlogLikeService
{
    @Autowired
    private BlogLikeMapper blogLikeMapper;

    /**
     * 查询点赞
     * 
     * @param id 点赞ID
     * @return 点赞
     */
    @Override
    public BlogLike selectBlogLikeById(Long id)
    {
        return blogLikeMapper.selectBlogLikeById(id);
    }

    /**
     * 查询点赞列表
     * 
     * @param blogLike 点赞
     * @return 点赞
     */
    @Override
    public List<BlogLike> selectBlogLikeList(BlogLike blogLike)
    {
        return blogLikeMapper.selectBlogLikeList(blogLike);
    }

    /**
     * 新增点赞
     * 
     * @param blogLike 点赞
     * @return 结果
     */
    @Override
    public int insertBlogLike(BlogLike blogLike)
    {
        blogLike.setCreateTime(DateUtils.getNowDate());
        return blogLikeMapper.insertBlogLike(blogLike);
    }

    /**
     * 修改点赞
     * 
     * @param blogLike 点赞
     * @return 结果
     */
    @Override
    public int updateBlogLike(BlogLike blogLike)
    {
        blogLike.setUpdateTime(DateUtils.getNowDate());
        return blogLikeMapper.updateBlogLike(blogLike);
    }

    /**
     * 批量删除点赞
     * 
     * @param ids 需要删除的点赞ID
     * @return 结果
     */
    @Override
    public int deleteBlogLikeByIds(Long[] ids)
    {
        return blogLikeMapper.deleteBlogLikeByIds(ids);
    }

    /**
     * 删除点赞信息
     * 
     * @param id 点赞ID
     * @return 结果
     */
    @Override
    public int deleteBlogLikeById(Long id)
    {
        return blogLikeMapper.deleteBlogLikeById(id);
    }

    /**
     * 统计点赞数量
     *
     * @param articleId 文章ID
     * @return 结果
     */
    @Override
    public int countLikeById(Long articleId) {
        return blogLikeMapper.countLikeById(articleId);
    }
}
